<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a {
            position: fixed;
            right: 50%;
            bottom: 5%;
            text-decoration: none;
            color: #000;
        }

        a:hover {
            color: red;
        }
    </style>
</head>

<body>
    <div>
        <a href="首页.html">返回首页</a>

    </div>
    <script>
        let random = Math.floor(Math.random() * 100 + 1)
        let count = 5
        while (count >= 0) {
            let num = +prompt('请输入一个1-100的数字')
            if (num > random) {
                alert('你猜的数字太大了')
            }
            else if (num < random) {
                alert('你猜的数字太小了')
            }
            else {
                alert('恭喜你猜对了')
                break
            }
            count--
            if (count === 0) {
                alert(`你已经没有机会了，正确答案是${random}`)
                break
            }
            alert('你还有' + count + '次机会')
        }
    </script>
</body>

</html>